package com.youxuit.youxu.kecheng.threadLocal.usage1;

import java.text.SimpleDateFormat;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池实现 日期转换工具类(多个任务访问 )
 */
public class DateFormatUsage02 {

    static  ExecutorService executorService = Executors.newFixedThreadPool(10);

    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {

            int finalI = i;
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    String date = new DateFormatUsage02().formatDate(finalI);
                    System.out.println(date);
                }
            }) ;

        }
        executorService.shutdown();

    }

    public String formatDate(long times) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd mm:hh:ss");
        return dateFormat.format(times * 1000);
    }
}
